<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Class: Builder::CSS</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Class</strong></td>
          <td class="class-name-in-header">Builder::CSS</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../../files/vendor/rails/activesupport/lib/active_support/vendor/builder-2_1_2/builder/css_rb.html">
                vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/builder/css.rb
                </a>
        <br />
            </td>
        </tr>

        <tr class="top-aligned-row">
            <td><strong>Parent:</strong></td>
            <td>
                <a href="../BlankSlate.html">
                BlankSlate
               </a>
            </td>
        </tr>
        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">

    <div id="description">
      <p>
Create a Cascading Style Sheet (<a href="CSS.html">CSS</a>) using Ruby.
</p>
<p>
Example usage:
</p>
<pre>
  css = Builder::CSS.new

  text_color      = '#7F7F7F'
  preferred_fonts = 'Helvetica, Arial, sans_serif'

  css.comment! 'This is our stylesheet'
  css.body {
    background_color '#FAFAFA'
    font_size        'small'
    font_family      preferred_fonts
    color            text_color
  }

  css.id!('navbar') {
    width            '500px'
  }

  css.class!('navitem') {
    color            'red'
  }

  css.a :hover {
    text_decoration  'underline'
  }

  css.div(:id =&gt; 'menu') {
    background       'green'
  }

  css.div(:class =&gt; 'foo') {
    background       'red'
  }
</pre>
<p>
This will yield the following stylesheet:
</p>
<pre>
  /* This is our stylesheet */
  body {
    background_color: #FAFAFA;
    font_size:        small;
    font_family:      Helvetica, Arial, sans_serif;
    color:            #7F7F7F;
  }

  #navbar {
    width:            500px;
  }

  .navitem {
    color:            red;
  }

  a:hover {
    text_decoration:  underline;
  }

  div#menu {
    background:       green;
  }

  div.foo {
    background:       red;
  }
</pre>

    </div>


   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000897">+</a>&nbsp;&nbsp;
      <a href="#M000899">&gt;</a>&nbsp;&nbsp;
      <a href="#M000898">&gt;&gt;</a>&nbsp;&nbsp;
      <a href="#M000904">class!</a>&nbsp;&nbsp;
      <a href="#M000902">comment!</a>&nbsp;&nbsp;
      <a href="#M000906">group!</a>&nbsp;&nbsp;
      <a href="#M000903">id!</a>&nbsp;&nbsp;
      <a href="#M000907">method_missing</a>&nbsp;&nbsp;
      <a href="#M000896">new</a>&nbsp;&nbsp;
      <a href="#M000908">nil?</a>&nbsp;&nbsp;
      <a href="#M000905">store!</a>&nbsp;&nbsp;
      <a href="#M000901">target!</a>&nbsp;&nbsp;
      <a href="#M000900">|</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">





      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Class methods</h3>

      <div id="method-M000896" class="method-detail">
        <a name="M000896"></a>

        <div class="method-heading">
          <a href="#M000896" class="method-signature">
          <span class="method-name">new</span><span class="method-args">(indent=2)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Create a <a href="CSS.html">CSS</a> builder.
</p>
<table>
<tr><td valign="top">out:</td><td><a href="../Object.html">Object</a> receiving the markup.1 <tt>out</tt>
must respond to <tt>&lt;&lt;</tt>.

</td></tr>
<tr><td valign="top">indent:</td><td>Number of spaces used for indentation (0 implies no indentation and no line
breaks).

</td></tr>
</table>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000896-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000896-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/builder/css.rb, line 101</span>
101:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">indent</span>=<span class="ruby-value">2</span>)
102:       <span class="ruby-ivar">@indent</span>      = <span class="ruby-identifier">indent</span>
103:       <span class="ruby-ivar">@target</span>      = []
104:       <span class="ruby-ivar">@parts</span>       = []
105:       <span class="ruby-ivar">@library</span>     = {}
106:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M000897" class="method-detail">
        <a name="M000897"></a>

        <div class="method-heading">
          <a href="#M000897" class="method-signature">
          <span class="method-name">+</span><span class="method-args">(part)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000897-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000897-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/builder/css.rb, line 108</span>
108:     <span class="ruby-keyword kw">def</span> <span class="ruby-operator">+</span>(<span class="ruby-identifier">part</span>)
109:       <span class="ruby-identifier">_join_with_op!</span> <span class="ruby-value str">'+'</span>
110:       <span class="ruby-keyword kw">self</span>
111:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000899" class="method-detail">
        <a name="M000899"></a>

        <div class="method-heading">
          <a href="#M000899" class="method-signature">
          <span class="method-name">&gt;</span><span class="method-args">(part)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000899-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000899-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/builder/css.rb, line 118</span>
118:     <span class="ruby-keyword kw">def</span> <span class="ruby-operator">&gt;</span>(<span class="ruby-identifier">part</span>)
119:       <span class="ruby-identifier">_join_with_op!</span> <span class="ruby-value str">'&gt;'</span>
120:       <span class="ruby-keyword kw">self</span>
121:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000898" class="method-detail">
        <a name="M000898"></a>

        <div class="method-heading">
          <a href="#M000898" class="method-signature">
          <span class="method-name">&gt;&gt;</span><span class="method-args">(part)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000898-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000898-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/builder/css.rb, line 113</span>
113:     <span class="ruby-keyword kw">def</span> <span class="ruby-operator">&gt;&gt;</span>(<span class="ruby-identifier">part</span>)
114:       <span class="ruby-identifier">_join_with_op!</span> <span class="ruby-value str">''</span>
115:       <span class="ruby-keyword kw">self</span>
116:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000904" class="method-detail">
        <a name="M000904"></a>

        <div class="method-heading">
          <a href="#M000904" class="method-signature">
          <span class="method-name">class!</span><span class="method-args">(arg, &amp;block)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000904-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000904-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/builder/css.rb, line 145</span>
145:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">class!</span>(<span class="ruby-identifier">arg</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
146:       <span class="ruby-identifier">_start_container</span>(<span class="ruby-value str">'.'</span><span class="ruby-operator">+</span><span class="ruby-identifier">arg</span>.<span class="ruby-identifier">to_s</span>, <span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">block_given?</span>)
147:       <span class="ruby-identifier">_css_block</span>(<span class="ruby-identifier">block</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block</span>
148:       <span class="ruby-identifier">_unify_block</span>
149:       <span class="ruby-keyword kw">self</span>
150:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000902" class="method-detail">
        <a name="M000902"></a>

        <div class="method-heading">
          <a href="#M000902" class="method-signature">
          <span class="method-name">comment!</span><span class="method-args">(comment_text)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Create a comment string in the output.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000902-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000902-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/builder/css.rb, line 134</span>
134:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">comment!</span>(<span class="ruby-identifier">comment_text</span>)
135:       <span class="ruby-ivar">@target</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot;/* #{comment_text} */\n&quot;</span>
136:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000906" class="method-detail">
        <a name="M000906"></a>

        <div class="method-heading">
          <a href="#M000906" class="method-signature">
          <span class="method-name">group!</span><span class="method-args">(*args, &amp;block)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000906-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000906-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/builder/css.rb, line 156</span>
156:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">group!</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
157:       <span class="ruby-identifier">args</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">arg</span><span class="ruby-operator">|</span>
158:         <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">arg</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Symbol</span>)
159:           <span class="ruby-identifier">instance_eval</span>(<span class="ruby-operator">&amp;</span><span class="ruby-ivar">@library</span>[<span class="ruby-identifier">arg</span>])
160:         <span class="ruby-keyword kw">else</span>
161:           <span class="ruby-identifier">instance_eval</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">arg</span>)
162:         <span class="ruby-keyword kw">end</span>
163:         <span class="ruby-identifier">_text</span> <span class="ruby-value str">', '</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">arg</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">last</span>
164:       <span class="ruby-keyword kw">end</span>
165:       <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block</span>
166:         <span class="ruby-identifier">_css_block</span>(<span class="ruby-identifier">block</span>)
167:         <span class="ruby-identifier">_unify_block</span>
168:       <span class="ruby-keyword kw">end</span>
169:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000903" class="method-detail">
        <a name="M000903"></a>

        <div class="method-heading">
          <a href="#M000903" class="method-signature">
          <span class="method-name">id!</span><span class="method-args">(arg, &amp;block)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000903-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000903-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/builder/css.rb, line 138</span>
138:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">id!</span>(<span class="ruby-identifier">arg</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
139:       <span class="ruby-identifier">_start_container</span>(<span class="ruby-value str">'#'</span><span class="ruby-operator">+</span><span class="ruby-identifier">arg</span>.<span class="ruby-identifier">to_s</span>, <span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">block_given?</span>)
140:       <span class="ruby-identifier">_css_block</span>(<span class="ruby-identifier">block</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block</span>
141:       <span class="ruby-identifier">_unify_block</span>
142:       <span class="ruby-keyword kw">self</span>
143:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000907" class="method-detail">
        <a name="M000907"></a>

        <div class="method-heading">
          <a href="#M000907" class="method-signature">
          <span class="method-name">method_missing</span><span class="method-args">(sym, *args, &amp;block)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000907-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000907-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/builder/css.rb, line 171</span>
171:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">method_missing</span>(<span class="ruby-identifier">sym</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
172:       <span class="ruby-identifier">sym</span> = <span class="ruby-node">&quot;#{sym}:#{args.shift}&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">first</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-constant">Symbol</span>)
173:       <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block</span>
174:         <span class="ruby-identifier">_start_container</span>(<span class="ruby-identifier">sym</span>, <span class="ruby-identifier">args</span>.<span class="ruby-identifier">first</span>)
175:         <span class="ruby-identifier">_css_block</span>(<span class="ruby-identifier">block</span>)
176:         <span class="ruby-identifier">_unify_block</span>
177:       <span class="ruby-keyword kw">elsif</span> <span class="ruby-ivar">@in_block</span>
178:         <span class="ruby-identifier">_indent</span>
179:         <span class="ruby-identifier">_css_line</span>(<span class="ruby-identifier">sym</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
180:         <span class="ruby-identifier">_newline</span>
181:         <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">self</span>
182:       <span class="ruby-keyword kw">else</span>
183:         <span class="ruby-identifier">_start_container</span>(<span class="ruby-identifier">sym</span>, <span class="ruby-identifier">args</span>.<span class="ruby-identifier">first</span>, <span class="ruby-keyword kw">false</span>)
184:         <span class="ruby-identifier">_unify_block</span>
185:       <span class="ruby-keyword kw">end</span>
186:       <span class="ruby-keyword kw">self</span>
187:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000908" class="method-detail">
        <a name="M000908"></a>

        <div class="method-heading">
          <a href="#M000908" class="method-signature">
          <span class="method-name">nil?</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
&quot;Cargo culted&quot; from Jim who also &quot;cargo culted&quot; it. See
xmlbase.rb.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000908-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000908-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/builder/css.rb, line 190</span>
190:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">nil?</span>
191:       <span class="ruby-keyword kw">false</span>
192:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000905" class="method-detail">
        <a name="M000905"></a>

        <div class="method-heading">
          <a href="#M000905" class="method-signature">
          <span class="method-name">store!</span><span class="method-args">(sym, &amp;block)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000905-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000905-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/builder/css.rb, line 152</span>
152:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">store!</span>(<span class="ruby-identifier">sym</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
153:       <span class="ruby-ivar">@library</span>[<span class="ruby-identifier">sym</span>] = <span class="ruby-identifier">block</span>.<span class="ruby-identifier">to_proc</span>
154:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000901" class="method-detail">
        <a name="M000901"></a>

        <div class="method-heading">
          <a href="#M000901" class="method-signature">
          <span class="method-name">target!</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Return the target of the builder
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000901-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000901-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/builder/css.rb, line 129</span>
129:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">target!</span>
130:       <span class="ruby-ivar">@target</span> <span class="ruby-operator">*</span> <span class="ruby-value str">''</span>
131:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000900" class="method-detail">
        <a name="M000900"></a>

        <div class="method-heading">
          <a href="#M000900" class="method-signature">
          <span class="method-name">|</span><span class="method-args">(part)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000900-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000900-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/builder/css.rb, line 123</span>
123:     <span class="ruby-keyword kw">def</span> <span class="ruby-operator">|</span>(<span class="ruby-identifier">part</span>)
124:       <span class="ruby-identifier">_join_with_op!</span> <span class="ruby-value str">','</span>
125:       <span class="ruby-keyword kw">self</span>
126:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>